CXX = g++
CXXFLAGS = -g -std=c++11 -I/opt/etherlab/include -I/usr/xenomai/include -I/usr/xenomai/include/trank -I/usr/xenomai/include/cobalt -I./ -I/opt/etherlab -D__XENO_COMPAT__ -D_GNU_SOURCE
LDFLAGS = -shared -Wl,@/usr/xenomai/lib/modechk.wrappers -Wl,@/usr/xenomai/lib/cobalt.wrappers -Wl,-rpath,/opt/etherlab/lib -Wl,-rpath,/usr/xenomai/lib -Wl,-rpath,/usr/local/lib
LDLIBS = -lethercat_rtdm -ltrank -lalchemy -lcopperplate -lcobalt -lmodechk -lmxml -L/opt/etherlab/lib -L/usr/xenomai/lib -L/usr/local/lib
SOURCES = device.cpp ecdata.cpp ecdriver.cpp ecio.cpp ecxml.cpp eeprom.cpp factory.cpp inexbot.cpp master.cpp nowio.cpp servo.cpp slave.cpp well.cpp
OBJECTS = $(SOURCES:.cpp=.o)
	TARGET = libecdriver.so
	DESTDIR = $(PWD)/lib
	VERSION = 1.0.0

all: $(DESTDIR)/$(TARGET)

$(DESTDIR)/$(TARGET): $(OBJECTS)
	    mkdir -p $(DESTDIR)
	        $(CXX) $(LDFLAGS) -o $@ $^ $(LDLIBS)

%.o: %.cpp
	    $(CXX) $(CXXFLAGS) -fPIC -c $< -o $@

clean:
	    rm -f $(OBJECTS) $(DESTDIR)/$(TARGET)

.PHONY: all clean
